<?php
/**
 * Created by dutuwang.net
 * User: adophper <hello@adophper.com>
 * Date: 2018/4/4
 * Time: 17:21
 */
?>
<div class="exhibition_list clearfix">
    <?php
    if (!empty($data['data'])) {
        foreach ($data['data'] as $val) {
    ?>
    <div class="item_row clearfix">
        <div class="item_row_img_box col-md-3 col-xs-3 col-sm-4">
            <div class="recomedBox_item_img_box img">
                <a class="text-center" href="<?=Yii::$app->urlManager->createUrl(['zhanhui/detail', 'id' => $val['id']])?>" target="_blank" title="<?=$val['title']?>"><img src="<?=$val['litpic']?>_350x210.jpg" alt="<?=$val['title']?>" /></a>
                <span class="flex f_center"><label class="compare_to" data-id="<?=$val['id']?>"><input type="checkbox"  id="compare_<?=$val['id']?>" <?=isset($compareData[$val['id']])?'checked="checked"':''?> /> &nbsp;加入对比</label></span>
            </div>
            <div class="recomedBox_item_min_tab flex">
                <a href="javascript:;" class="flex_tel go_follow" data-id="<?=$val['id']?>" data-follow="<?=$val['is_follow']?>"><i class="flex f_center"><?=$val['is_follow']?'取消':''?>关注</i><em class="flex f_center large glyphicon glyphicon-heart"></em></a>
                <a href="<?=Yii::$app->urlManager->createUrl(['zhanhui/detail', 'id' => $val['id']])?>#photo" class="flex_tel"><i class="flex f_center">集锦</i><em class="flex f_center iconfont top">&#xe649;</em></a>
                <a href="<?=Yii::$app->urlManager->createUrl(['zhanhui/detail', 'id' => $val['id']])?>#video" class="flex_tel"><i class="flex f_center">VR</i><em class="flex f_center iconfont large">&#xe77e;</em></a>
                <a href="<?=Yii::$app->user->isGuest ? Yii::$app->urlManager->createUrl(['member/login']) : Yii::$app->urlManager->createUrl(['zhanhui/detail', 'id' => $val['id']])?>#comments" class="flex_tel"><i class="flex f_center">评论</i><em class="flex f_center iconfont small pencil">&#xe608;</em></a>
            </div>
        </div>
        <div class="item_row_txt_box col-md-9 col-xs-9 col-sm-8">
            <div class="item_row_title clearfix">
                <div class="item_row_exhibition_name pull-left">
                    <a href="<?=Yii::$app->urlManager->createUrl(['search/index', 'type' => 'category', 'value' => $val['category_id']])?>" class="t_red" target="_blank">[<?=$val['category_name']?>]</a>
                    <a href="<?=Yii::$app->urlManager->createUrl(['zhanhui/detail', 'id' => $val['id']])?>" target="_blank" title="<?=$val['title']?>"><?=$val['title']?></a>
                </div>

                <div class="item_row_qrcode pull-left">
                    <i class="glyphicon glyphicon-qrcode list_qrcode" data-parent=".item_row_qrcode"></i>
                    <div class="wCode_mark sel hidden ">
                        <span><img src="<?=$val['wechat_qrcode']?>" /></span>
                        <em>进入展会手机官网</em>
                    </div>
                </div>
                <div class="pull-right flex">
                    <div class="item_row_follow"><i class="glyphicon glyphicon-heart"></i> <span>关注度</span> <i id="follow_number_<?=$val['id']?>"><?=$val['follow_number']?></i></div>
                    <div class=" rating-stars" title="<?=$val['score']?>">
                        <span class="empty-stars">
                            <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                            <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                            <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                            <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                            <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                        </span>
                        <span class="filled-stars" style="width: <?=$val['score']*20?>%;">
                            <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                            <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                            <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                            <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                            <span class="star"><i class="glyphicon glyphicon-star"></i></span>
                        </span>
                    </div>
                </div>
            </div>
            <div class="item_row_other">
                <span class="t_o"><i class="iconfont t_red">&#xe615;</i><?=Yii::t('frontend', 'exhibition_time')?>：<?=$val['show_start']?><i><?=Yii::t('frontend', 'to')?></i><?=$val['show_end']?></span>
                <span class="t_o"><i class="iconfont t_red">&#xe620;</i><?=Yii::t('frontend', 'place')?>：<?=$val['city']?></span>
            </div>
            <div class="item_row_desc">
                <p class="item_row_desc_span">展会介绍：</p>
                <div class="item_row_desc_content"><?=\common\helpers\TStringHelper::utf8_substr(strip_tags($val['introduce']), 0, 300, '...')?></div>
            </div>
        </div>
    </div>
    <?php
        }
    }else{
        ?>
        <div class="col-md-12 text-center" style="padding: 50px 0; font-size: 18px;"><p>暂无数据...</p></div>
        <?php
    }
    ?>
</div>
<div class="detailBox_whitemin list-page text-center">
    <?php
    if (!empty($data['data'])) {
        echo \yii\widgets\LinkPager::widget([
            'pagination' => $data['page'],
            'maxButtonCount' => 6,
            'nextPageLabel' => Yii::t('frontend', 'next_page'),
            'prevPageLabel' => Yii::t('frontend', 'prev_page'),
            'firstPageLabel' => Yii::t('frontend', 'first_page'),
            'lastPageLabel' => Yii::t('frontend', 'last_page'),
        ]);
    }
    ?>
</div>
<script>
    var userId = '<?=Yii::$app->user->getId()?>';
    $(function(){
        $(".go_follow").on('click', function(e){
            if (userId == '') {
                alert('请先登录');
                return false;
            }
            var is_follow = $(this).data('follow');
            var id = $(this).data('id');
            var follow_number = parseInt($("#follow_number_"+id).text());
            $.post('<?=Yii::$app->urlManager->createUrl(['zhanhui/go-follow'])?>', {id: id}, function(response){
                alert(response.msg);
                if (response.code == 0) {
                    if (is_follow) {
                        $(".go_follow[data-id="+id+"]").data('follow', 0);
                        $(".go_follow[data-id="+id+"]").find('i').text('关注');
                        $("#follow_number_"+id).text(follow_number - 1);
                    }else{
                        $(".go_follow[data-id="+id+"]").data('follow', 1);
                        $(".go_follow[data-id="+id+"]").find('i').text('取消关注');
                        $("#follow_number_"+id).text(follow_number + 1);
                    }
                }
            }, 'json');
        })
    })
</script>